package cn.bugstack.springframework.test;

import cn.bugstack.springframework.BeanDefinition2;
import cn.bugstack.springframework.BeanFactory2;
import cn.bugstack.springframework.test.bean.UserService;
import org.junit.Test;

public class ApiTest2 {

    @Test
    public void test_bean(){
        //1.初始化bean工厂
        BeanFactory2 beanFactory2 = new BeanFactory2();

        //2.注入bean
        BeanDefinition2 beanDefinition2 = new BeanDefinition2(new UserService());
        beanFactory2.registerBeanDefinition("userService",beanDefinition2);


        // 3.获取bean
        UserService userService = (UserService)beanFactory2.getBean("userService");
        userService.queryUserInfo();


    }
}
